package com.spic.business.riskbase.hierarchy.controller;

import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.spic.common.log.annotation.Log;
import com.spic.common.log.enums.BusinessType;
import com.spic.business.riskbase.hierarchy.domain.RiskDescription;
import com.spic.business.riskbase.hierarchy.service.IRiskDescriptionService;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.page.TableDataInfo;

/**
 * riskDescriptionController
 *
 * @author ruoyi
 * @date 2023-04-14
 */
@RestController
@RequestMapping("/risk/riskDescription")
public class RiskDescriptionController extends BaseController
{
    @Autowired
    private IRiskDescriptionService riskDescriptionService;

    /**
     * 查询riskDescription列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RiskDescription riskDescription)
    {
        startPage();
        List<RiskDescription> list = riskDescriptionService.selectRiskDescriptionList(riskDescription);
        return getDataTable(list);
    }

    /**
     * 导出riskDescription列表
     */
    @Log(title = "riskDescription", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RiskDescription riskDescription) throws IOException {
        List<RiskDescription> list = riskDescriptionService.selectRiskDescriptionList(riskDescription);
        ExcelUtil<RiskDescription> util = new ExcelUtil<RiskDescription>(RiskDescription.class);
        util.exportExcel(response, list, "riskDescription数据");
    }

    /**
     * 获取riskDescription详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(riskDescriptionService.selectRiskDescriptionById(id));
    }

    /**
     * 新增riskDescription
     */
    @Log(title = "riskDescription", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RiskDescription riskDescription)
    {
        return toAjax(riskDescriptionService.insertRiskDescription(riskDescription));
    }

    /**
     * 修改riskDescription
     */
    @Log(title = "riskDescription", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RiskDescription riskDescription)
    {
        return toAjax(riskDescriptionService.updateRiskDescription(riskDescription));
    }

    /**
     * 删除riskDescription
     */
    @Log(title = "riskDescription", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(riskDescriptionService.deleteRiskDescriptionByIds(ids));
    }
}
